package pers.csw.lookBook.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import pers.csw.lookBook.common.constant.ErrorCode;

/**
 * @author csw
 */
@Getter
@AllArgsConstructor
public class Res {
    private final String code;
    private Object data;
    private final String msg;

    private Res(){
        this.code = ErrorCode.SUCCESS.code();
        this.msg = ErrorCode.SUCCESS.message();
    }
    private Res(Object data){
        this();
        this.data = data;
    }
    private Res(ErrorCode errorCode) {
        this.code = errorCode.code();
        this.msg = errorCode.message();
    }

    public Res(String i, String msg) {
        this.code = i;
        this.msg = msg;
    }

    public static Res success() {
        return new Res();
    }

    public static Res success(Object data) {
        return new Res(data);
    }

    public static Res fail(ErrorCode errorCode) {
        return new Res(errorCode);
    }

    public static Res error() {
        return new Res(ErrorCode.SYSTEM_ERROR);
    }


}
